package com.example.theoretical_verification.collection;

import java.util.LinkedList;

public class MyLinkedList {
    public static void main(String[] args) {
        // 创建一个 LinkedList
        LinkedList<String> linkedList = new LinkedList<>();

        // 向 LinkedList 中添加元素
        linkedList.add("A");
        linkedList.add("B");
        linkedList.add("C");
        linkedList.add("D");
        linkedList.add("E");

        // 检查是否包含指定的元素
        boolean contains = linkedList.contains("C");
        System.out.println("LinkedList 是否包含元素 C：" + contains);

        // 获取D元素所在的索引
        int dIndex = linkedList.indexOf("D");
        // 然后把D的值改为小写d
        linkedList.set(dIndex, "d");
        String dValue = linkedList.get(dIndex);
        System.out.println("这是改之后D的值" + dValue);
    }
}

